import Vue from 'vue'
import VueRouter from "vue-router"

import App from './App.vue'
import Pc from './components/Pc.vue'
import Mobile from './components/Mobile.vue'
import ArticleList from './components/ArticleList.vue'
import MobileArticle from './components/MobileArticle.vue'
import MobileArticleList from './components/MobileArticleList.vue'
import MobileFullTestSearch from './components/MobileFullTestSearch.vue'
import FullTextSearch from './components/FullTextSearch.vue'
import Article from "./components/Article";
import Article01 from "./components/Article01";
import listVUE from "./components/list.vue";
import HospitalNewspaper from "./components/HospitalNewspaper";
import HospitalSummedup from "./components/HospitalSummedup";
import { Pagination } from 'vant';
Vue.use(Pagination);

import BaiduMap from 'vue-baidu-map'
Vue.use(BaiduMap, {
  // ak 是在百度地图开发者平台申请的密钥 详见 http://lbsyun.baidu.com/apiconsole/key */
  ak: 'jpNT1IpnhL8DXFPEhpfoNfFZfCi4wEwG'
})

import MobileKesdh from './components/MobileKesdh.vue'
import MobileZhuanjxq from './components/MobileZhuanjxq.vue'
import MobileZhuanjlb from './components/MobileZhuanjlb.vue'

Vue.use(VueRouter);
const originalPush = VueRouter.prototype.push
   VueRouter.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}

Vue.config.productionTip = false;

const routes = [
  { path: "/mobileZhuanjxq/:id", component: MobileZhuanjxq },
  { path: "/mobileZhuanjlb/:id", component: MobileZhuanjlb },
  { path: "/mobileKesdh", component: MobileKesdh },//手机端科室导航
  { path: "/", component: Pc }, //pc端首页
  { path: "/mobile", component: Mobile }, //手机端首页
  { path: "/ArticleList", component: ArticleList, meta: {keepAlive: true}},//文章列表
  { path: "/Article/:id", component: Article },//文章
  { path: "/Article01/:id", component: Article01 },//文章
  { path: "/listVUE/:id", component: listVUE },//列表
  { path: "/MobileArticleList", component: MobileArticleList },//文章列表
  { path: "/MobileArticle/:id", component: MobileArticle },//移动端文章
  { path: "/FullTextSearch", component: FullTextSearch },//全文检索
  { path: "/MobileFullTestSearch", component: MobileFullTestSearch },//全文检索
  { path: "/hospitalNewspaper", component: HospitalNewspaper },//党建工作
  { path: "/HospitalSummedup", component: HospitalSummedup },//手机端
];

const router = new VueRouter({
  routes // (缩写) 相当于 routes: routes
});

const setHtmlFontSize = () => {
  const htmlDom = document.getElementsByTagName('html')[0];
  let htmlWidth = document.documentElement.clientWidth || document.body.clientWidth;
  if (htmlWidth >= 750) {
    htmlWidth = 750;
  }
  if (htmlWidth <= 320) {
    htmlWidth = 320;
  }
  htmlDom.style.fontSize = `${htmlWidth / 7.5}px`;
};
window.onresize = setHtmlFontSize;
setHtmlFontSize();


new Vue({
  router,
  render: h => h(App)
}).$mount("#app");
